package MainProgram;

import java.util.Arrays;

/**
 * Generates the x- and y-arguments of sinus function.
 */
public class SinusCreator implements DataCreator {

    private double[][] trainingSet;
    private double[][] desiredOutput;
    private double[] xValues;
    private double[] yValues;

    /**
     * Creates the x- and y-arguments of sinus function.
     *
     * @param size Number of elements to generate.
     */
    public SinusCreator(int size) {

        xValues = new double[size];
        yValues = new double[size];
        for (int i = 0; i < xValues.length; i += 1) {
            xValues[i] = i / (double) size;
            yValues[i] = Math.sin((2 * Math.PI / size) * i);
        }
    }

    /**
     * Returns the set of training data.
     * @return 
     */
    @Override
    public double[][] getTrainingSet() {
//        this.trainingSet = new double[1][xValues.length];
//        this.trainingSet[0] = this.xValues;
        //Agata approach:
        this.trainingSet = new double[xValues.length][1];
        for (int i = 0; i < this.xValues.length; i++) {
            this.trainingSet[i][0] = this.xValues[i];
        }
        
        return this.trainingSet;
    }
    
    public double[] getXValues(){
    	return xValues;
    }
    /**
     * Returns the set of desired output data.
     * @return 
     */
    @Override
    public double[][] getDesiredOutput() {
//        this.desiredOutput = new double[1][yValues.length];
//        this.desiredOutput[0] = this.yValues;
        this.desiredOutput = new double[this.yValues.length][1];
        for (int i = 0; i < this.yValues.length; i++) {
            this.desiredOutput[i][0] = this.yValues[i];
        }
        
        return this.desiredOutput;
    }    
    
    @Override
    public String toString() {
        return "SinusCreator{\n\t" + "xValues=" + Arrays.toString(xValues)
                + "\n\tyValues=" + Arrays.toString(yValues) + "\n\t}";
    }
}
